﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using WpfSnqkGasAnalysis.Common;
using WpfSnqkGasAnalysis.Model;

namespace WpfSnqkGasAnalysis
{
    /// <summary>
    /// 编辑按钮、校对按钮，判断是否显示
    /// </summary>
    /// 创建时间：2022-12-9 15:51:19。作者：王浩力
    internal class Gas_analysis_o_stepConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (int.TryParse(value.ToString(), out int o_step))
            {
                //编辑按钮
                if (System.Convert.ToString( parameter )=="1")
                {
                    //修改时间：2023-2-9 11:14:48。作者：王浩力。超级管理员任何时间都可以修改
                    //修改时间：2023-1-10 09:31:46。作者：王浩力。录入人可以自己编辑，客户提的
                    if (GetLoginHelpter.CurrentLoginUser().User_account.Equals(CommonConfig.SupperUserAccount)
                   )
                    {
                        return System.Windows.Visibility.Visible;
                    }
                    if (o_step <= 1 )
                    {
                        return System.Windows.Visibility.Visible;
                    }
                    return System.Windows.Visibility.Collapsed;
                }
                else
                {
                    //校对按钮
                    if ((o_step <= 1 || o_step == 3)
                            && (GetLoginHelpter.CurrentLoginUser().Role_id == "校对人"
                            //超级账号
                            || GetLoginHelpter.CurrentLoginUser().User_account.Equals(CommonConfig.SupperUserAccount)
                            )
                    )
                    {
                        return System.Windows.Visibility.Visible;
                    }
                }                
                return System.Windows.Visibility.Collapsed;
            }
            else
            {
                return System.Windows.Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
